package com.sunday.gateway.mock.security.webflux.login.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationEntryPoint;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Slf4j
public class RedirectServerAuthenticationEntryPointHandler extends RedirectServerAuthenticationEntryPoint {

    public RedirectServerAuthenticationEntryPointHandler(String location) {
        super(location);
    }

    /**
     * 发起认证流程
     */
    @Override
    public Mono<Void> commence(ServerWebExchange exchange, AuthenticationException ex) {
        log.info("鉴权失败 url : {}", exchange.getRequest().getURI().getPath());
        return super.commence(exchange, ex);
    }
}
